/* Copyright (C)
 * 2017 - Xianlee.Wu  xianleewu@163.com
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */

#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "unistd.h"
#include "wifiap.h"
#include "audiochat.h"

#define DEFAULT_AUDIO_PORT      6060
#define DEFAULT_REMOTE_IP       "192.168.100.3"
#define DEFAULT_SERVER_IP       "192.168.100.1"
#define DEFAULT_REMOTE_PORT     6060
#define DEFAULT_AUDIO_FORMAT    "audio/pcma/8000"
#define DEFAULT_AUDIO_BITRATE   64000

int main(int argc, char* argv[])
{
    if (argc > 2) {
        wlan_accesspoint_start(argv[1], argv[2]);
        printf("Server created %s,%s\n", argv[1], argv[2]);
        start_audio_chat(DEFAULT_AUDIO_PORT, DEFAULT_REMOTE_IP, DEFAULT_REMOTE_PORT, DEFAULT_AUDIO_FORMAT, DEFAULT_AUDIO_BITRATE);
    } else {
        printf("You didn't set role of app, so be client!\n");
        start_audio_chat(DEFAULT_AUDIO_PORT, DEFAULT_SERVER_IP, DEFAULT_REMOTE_PORT, DEFAULT_AUDIO_FORMAT, DEFAULT_AUDIO_BITRATE);
    }

    while (1) {
        // TODO:
        sleep(1);
    }

    return 0;
}
